<?php

namespace app\api\controller;

use app\api\controller\Base;
use app\api\service\OrderService;
use app\api\service\DeviceService;
use think\Db;
use think\Exception;
use think\Log;
use think\Request;

class Device extends Base
{

    public function __construct()
    {
        // todo 
    }

    // 扫码器传递参数核销
    public function qrCodeCallback()
    {
        $request = Request::instance()->post();
        parent::validate($request, 'ApproachValidate');
        Log::info('扫码器回调处理：' . date('Y-m-d H:i:s'));
        $qr_code = self::unlock_url($request['qr_number'], 'password');
        Log::info('解码二维码：' . $qr_code);
        $this->cancellation($qr_code);
    }

    //执行核销
    public function cancellation($qr_code)
    {
        return (new DeviceService())->cancellation($qr_code);
    }

    // 更新核销二维码
    public function qrCodeUpdate()
    {
        $data = (new DeviceService())->qrCodeUpdate();
        $this->success('success', $data);
    }



}